From 4d3817aae9639e6a6cc26bd47edd46dd8c2aa3ed Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Tue, 27 Mar 2007 00:54:05 +0100 Subject: [PATCH] Convert XendPIFMetrics into an autoplug class. Signed-off-by: Ewan Mellor --- tools/python/xen/xend/XendAPI.py | 20 +++++--------------- tools/python/xen/xend/XendPIFMetrics.py | 8 +++++--- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/tools/python/xen/xend/XendAPI.py b/tools/python/xen/xend/XendAPI.py index 2fb8496e83..f35a1fa418 100644 --- a/tools/python/xen/xend/XendAPI.py +++ b/tools/python/xen/xend/XendAPI.py @@ -34,6 +34,7 @@ from xen.xend.XendClient import ERROR_INVALID_DOMAIN from xen.xend.XendLogging import log from xen.xend.XendNetwork import XendNetwork from xen.xend.XendTask import XendTask +from xen.xend.XendPIFMetrics import XendPIFMetrics from xen.xend.XendVMMetrics import XendVMMetrics from xen.xend.XendAPIConstants import * @@ -438,8 +439,9 @@ class XendAPI(object): } autoplug_classes = { - 'network' : XendNetwork, - 'VM_metrics' : XendVMMetrics, + 'network' : XendNetwork, + 'VM_metrics' : XendVMMetrics, + 'PIF_metrics' : XendPIFMetrics, } # Cheat methods @@ -1071,21 +1073,9 @@ class XendAPI(object): def PIF_metrics_get_all(self, _): return xen_api_success(XendNode.instance().pif_metrics.keys()) - def _PIF_metrics_get(self, ref): + def _PIF_metrics_get(self, _, ref): return XendNode.instance().pif_metrics[ref] - def PIF_metrics_get_record(self, _, ref): - return xen_api_success(self._PIF_metrics_get(ref).get_record()) - - def PIF_metrics_get_io_read_kbs(self, _, ref): - return xen_api_success(self._PIF_metrics_get(ref).get_io_read_kbs()) - - def PIF_metrics_get_io_write_kbs(self, _, ref): - return xen_api_success(self._PIF_metrics_get(ref).get_io_write_kbs()) - - def PIF_metrics_get_last_updated(self, _1, _2): - return xen_api_success(now()) - # Xen API: Class VM # ---------------------------------------------------------------- diff --git a/tools/python/xen/xend/XendPIFMetrics.py b/tools/python/xen/xend/XendPIFMetrics.py index 36a1e582f4..a94736c234 100644 --- a/tools/python/xen/xend/XendPIFMetrics.py +++ b/tools/python/xen/xend/XendPIFMetrics.py @@ -39,11 +39,13 @@ class XendPIFMetrics: return pifs_util[pifname][n] return 0.0 - def get_record(self): + def get_last_updated(self): import xen.xend.XendAPI as XendAPI + return XendAPI.now() + + def get_record(self): return {'uuid' : self.uuid, - 'PIF' : self.pif.uuid, 'io_read_kbs' : self.get_io_read_kbs(), 'io_write_kbs' : self.get_io_write_kbs(), - 'last_updated' : XendAPI.now(), + 'last_updated' : self.get_last_updated(), } -- 2.30.2